<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>VUE3</title>
  </head>
  <body>
    <div id="app"></div>

    <template id="tpl">
      <ul>
        <li v-for="res in resources" :key="res">{{ res }}</li>
      </ul>
      <div>
        <input
          @keyup.enter="addResource"
          v-model="newResource"
          placeholder="输入资源名"
          required
        />
      </div>
    </template>

    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script>
      Vue.createApp({
        template: "#tpl",
        data() {
          return {
            resources: [
              "圣女的魔力是万能的",
              "修女2",
              "天使与龙的轮舞",
              "大楼里只有谋杀",
              "万卷风雅集",
            ],
            newResource: "",
          };
        },
        methods: {
          addResource() {
            // this.resources.push(this.newResource);
            this.resources = [...this.resources, this.newResource];
            this.newResource = "";
          },
        },
      }).mount("#app");
    </script>
  </body>
</html>
